<?php

namespace Biz\model\wiki;

/**
 * wiki 榜单周期表
 * Class WikiRankingWeek
 * @package Biz\model\wiki
 */
class WikiRankingWeek extends \Doraemon\pockets\datebase\BaseDbModel
{
    const _CONFIG_FILE_ = 'db_store';

    const _CONFIG_SELECT_ = 'db_store';

    const _DATABASE_ = 'store';

    const _TABLE_NAME = 'wiki_ranking_week';

    public static function getByWhere($where)
    {
        return self::get('*', $where);
    }

    public static function selectByWhere($where, $select = '*')
    {
        $list = self::select($select, $where);
        return $list;
    }

    public static function selectCountWhere($where)
    {
        $count = self::count('id', $where);
        return $count;
    }


    public static function insertData($data)
    {
        $ret = self::insert($data);
        if ($ret->errorCode() !== '00000') {
            return false;
        }
        return self::id();
    }


    public static function updateData($data, $where)
    {
        $ret = self::update($data, $where);
        if ($ret->errorCode() !== '00000') {
            return false;
        }
        return true;
    }


    public static function getList($pageSize , $page)
    {
        $where = [
            "ORDER" => ['ranking_day' => 'DESC'], // 默认降序
            "LIMIT" => [($page - 1) * $pageSize, $pageSize]
        ];
        return self::select("*" , $where);
    }

}